/*************************************************
Author: will
Date: 8/29/2012
Description:
Notes: 
*************************************************/

#ifndef __CBattleRandom_h__
#define __CBattleRandom_h__

#include <stdlib.h>
#include <sys/time.h>
#include <time.h>

class CBattleRandom
{
public:
    //roll取一个随机数 不包含max
    static int GetRand(unsigned int iMax)
    {
        if (iMax == 0)
        {
            return 0;
        }

        if (!m_bInited)
        {
            Init();
        }

        return (unsigned int)rand() % iMax;
    }
private:
    static bool m_bInited;

    static void Init()
    {
        struct timeval tv;
        gettimeofday(&tv,NULL);
        srand((unsigned int)(tv.tv_sec + tv.tv_usec));
        m_bInited = true;
    }
};

#endif // __CBattleRandom_h__

